.text
.global _start
_start:

//LED2---------------------GPL2_0
//LED3---------------------GPK1_1

#define GPL2CON	0x11000100
#define GPL2DAT	0x11000104

#define GPK1CON	0x11000060
#define GPK1DAT	0x11000064

ldr r0, =GPL2CON
ldr r1, [r0]
bic r1, r1, #0x0F
orr r1, r1, #0x01
str r1, [r0]

ldr r0, =GPL2DAT	//LED2亮
ldr r1, [r0]
bic r1, r1, #0x01
orr r1, r1, #0x01
str r1, [r0]
ldr r2,=0xffffff

ldr r0, =GPK1CON	//LED3亮
ldr r1, [r0]
bic r1, r1, #0xF0
orr r1, r1, #0x10
str r1, [r0]

leds_loop:

ldr r0, =GPL2DAT	//亮
ldr r1, [r0]
bic r1, r1, #0x01
orr r1, r1, #0x01
str r1, [r0]
ldr r2,=0xffffff
bl delay

ldr r0, =GPL2DAT	//灭
ldr r1, [r0]
bic r1, r1, #0x01
//orr r1, r1, #0x01
str r1, [r0]
ldr r2,=0xffffff
bl delay

ldr r0, =GPK1DAT	//亮
ldr r1, [r0]
bic r1, r1, #0x02
orr r1, r1, #0x02
str r1, [r0]
ldr r2,=0xffffff
bl delay

ldr r0, =GPK1DAT	//灭
ldr r1, [r0]
bic r1, r1, #0x02
#orr r1, r1, #0x02
str r1, [r0]
ldr r2,=0xffffff
bl delay

b leds_loop

halt_loop:
	b halt_loop
	
delay:
	//跑马灯延时程序
	sub r2,r2,#1 //sub 减法
	cmp r2,#0x0 //将r0 与0比较
	bne delay //b是跳 ne 是不相等 ，不相等就跳到delay
	mov pc,lr //lr 里存的是调用函数时的下一条指令，让Pc指针指向lr就可以完成函数的返回
